Skip to content

Conversation

@jbrinkman
Copy link
Owner

Summary

Fixes the issue where HTML reports showed correct counts but no detail data in the Breaking Changes, Added Items, and Removed Items sections.

Root Cause

The issue was caused by Scriban's {{ include }} directive not properly passing template context to included templates. When the main layout template tried to include the change-group template with section data, the context wasn't being passed correctly, resulting in empty template variables.

Solution

  • Replaced {{ include }} directives with custom Scriban function: Created RenderChangeGroup custom function that manually handles template rendering with proper context
  • Updated main layout template: Modified main-layout.scriban to use the new custom function instead of problematic include directives
  • Improved template context management: Ensured all section data (added, removed, modified, breaking changes) is properly passed to templates

Changes Made

  1. HtmlFormatterScriban.cs:

    • Removed pre-parsed template caching that was interfering with context
    • Added RenderChangeGroup custom function for reliable template rendering
    • Improved error handling and template context management
  2. main-layout.scriban:

    • Replaced {{ include "change-group" section }} with {{ render_change_group section }}
    • Uses new custom function approach for all change type sections
  3. Test Coverage:

    • Added comprehensive HtmlFormatterScribanTests.cs with 5 test scenarios
    • Tests cover all change types: added, removed, modified, breaking changes
    • Validates HTML structure, data presence, and proper styling

Testing

All HTML formatter tests pass (5/5):

  • Format_WithAddedItems_IncludesAddedSection
  • Format_WithRemovedItems_IncludesRemovedSection
  • Format_WithModifiedItems_IncludesModifiedSection
  • Format_WithBreakingChanges_IncludesBreakingSection
  • Format_WithMixedChanges_IncludesAllSections

Impact

  • Fixed: HTML reports now display complete detail data for all change sections
  • Maintained: All existing functionality preserved
  • Improved: More robust template rendering with better error handling
  • Enhanced: Comprehensive test coverage prevents regression

Closes #23

- Replaced problematic {{ include }} directives with custom RenderChangeGroup function
- Added comprehensive test coverage for HTML formatter with all change types
- Fixed template context passing issue that caused empty sections
- All HTML formatter tests now pass (5/5)

Fixes #23
@jbrinkman jbrinkman requested a review from Copilot July 27, 2025 13:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a critical issue where HTML reports showed correct summary counts but displayed no detail data in the Breaking Changes, Added Items, and Removed Items sections. The root cause was Scriban's {{ include }} directive failing to properly pass template context to included templates.

  • Replaced problematic {{ include }} directives with a custom RenderChangeGroup function that manually handles template rendering with proper context
  • Updated the main layout template to use the new custom function approach
  • Added comprehensive test coverage with 5 test scenarios covering all change types

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

File Description
HtmlFormatterScribanTests.cs New comprehensive test file covering all HTML formatter scenarios including added, removed, modified, and breaking changes
main-layout.scriban Updated to use custom render_change_group function instead of problematic include directive
HtmlFormatterScriban.cs Removed template caching, added custom RenderChangeGroup function for reliable template rendering with proper context
CompareCommand.cs Minor command option alias addition for output file parameter
Comments suppressed due to low confidence (1)

tests/DotNetApiDiff.Tests/Reporting/HtmlFormatterScribanTests.cs:147

  • [nitpick] The test method name suggests it tests signature details, but based on the description this appears to be testing modified items. Consider renaming to Format_WithModifiedItems_IncludesModifiedSection to be consistent with other test names in the file.
    public void Format_WithSignatures_IncludesSignatureDetails()

Signed-off-by: jbrinkman <joe.brinkman@improving.com>
Signed-off-by: jbrinkman <joe.brinkman@improving.com>
@jbrinkman jbrinkman merged commit eccf9c6 into main Jul 27, 2025
7 checks passed
@jbrinkman jbrinkman deleted the fix/html-report-missing-details branch July 27, 2025 14:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

HTML Report Missing Detail Data - Only Summary Counts Displayed

2 participants